#define _CRT_SECURE_NO_WARNINGS
#include <iostream>
#include <vector>

using namespace std;

int maxSubArray(vector<int>&& nums) {
    int dp[101000] = { 0 };
    int n = nums.size();
    int ret = INT_MIN;
    for (int i = 1; i <= n; ++i)
    {
        dp[i] = max(dp[i - 1] + nums[i - 1], nums[i - 1]);
        ret = max(ret, dp[i]);
    }

    return  ret;
}

int main()
{
    maxSubArray({ -2,1,-3,4,-1,2,1,-5,4 });
	return 0;
}